﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RAMED
{
    public partial class DemandeDevalidationForm : Form
    {

        private CORRECTION correction = new CORRECTION();

        public CORRECTION Correction
        {
            get { return correction; }
            set { correction = value; }
        }



        public Recherche_correction recherche_correction = new Recherche_correction();


        public DemandeDevalidationForm()
        {
            InitializeComponent();
            
        }




        public void remplirChamps()
        {

            NDemandeLbl.Text = correction.Num_dossier.Value.ToString();
            Nomlabel.Text = correction.Nom;
            PrenomLabel.Text = correction.Prénom;
            cinLabel.Text = correction.Cin;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            RAMEDEntities1 context = SingletonContext.GetContext();
            CORRECTION correctionAVlider = new CORRECTION();
            correctionAVlider = context.CORRECTIONs.Where(c => c.id_CORRECTION == Correction.id_CORRECTION).First();
            correctionAVlider.Date_demande_dévalidation = DateTime.Now;
            correctionAVlider.Num_demande = utitlitaire.CasterString(NDemandeTextBox.Text);
            correctionAVlider.Motif = MotifTextBox.Text;
            context.SaveChanges();
            SendMail.Send("ramedchefchouen@interieur.gov.ma", "ramedchefchouen@interieur.gov.ma", "DEVALIDATION DE DEMANDE", "");
            this.Dispose();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void Button21_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            this.Dispose();

        }

        private void DemandeDevalidationForm_Load(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }
    }
}
